import Http from "@/http"
import { dictionaryItemByCategoryApi } from "../system/Dictionary"

export function pageApi(params:any) {
    return Http.post('device/page', params)
}

export function saveApi(params:any) {
    return params.id ? Http.put('device/update/' + params.id, params) : Http.post('device/add', params)
}

export function saveBatchApi(params:any) {
    return Http.post('device/add/batch', params)
}


export function deleteApi(id) {
    return Http.delete('device/delete/' + id)
}


export function chargingTypeApi() {
    return dictionaryItemByCategoryApi('CHARGING_TYPE')
}

export function deviceCategoryApi() {
    return dictionaryItemByCategoryApi('DEVICE_TYPE')
}


export function batchUnbindTenantApi(ids:any[]) {
    return Http.post('device/batch/unbind/tenant', {ids})
}

export function batchBindTenantApi(ids:any[], owner:number) {
    return Http.post('device/batch/bind/tenant', {ids, owner})
}

export function portApi(id:number) {
    return Http.get('device/port/' + id)
}


export function getWarnApi(id, port, fieldId) {
    return Http.get(`device/warn/setting/${id}/${port}/${fieldId}`)
}

export function saveWarnApi(id, port, fieldId, params) {
    return Http.post(`device/warn/setting/${id}/${port}/${fieldId}`, params)
}


export function deviceDataRecordPageApi(id, port, fieldId, params) {
    return Http.post(`device/data/record/page/${id}/${port}/${fieldId}`, params)
}

export function ownedDeviceApi(){
    return Http.get('device/owned/device')
}


export function devicePortFieldDataRecordExportApi(id, port, fieldId, params) {
    return Http.post(`device/data/record/export/${id}/${port}/${fieldId}`, params)
}




export function queryProductListApi(){
    return Http.get('device/queryProductList')
}



export function getParams(deviceId:number) {
    //reutrn Http.get('device/')
}

export function sendDeviceSetting(deviceIds:number[]) {
    return Http.post('device/pushSetting', deviceIds)
}